package com.example.pictureview.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.example.pictureview.R;
import com.example.pictureview.widget.ImageLoader;

import java.util.List;

/**
 * Created by Administrator on 2017/9/20 0020.
 */

public class VideoAdapter extends BaseAdapter {
    private final List<String> mPaths;

    private final Context mContext;
    private final ImageLoader mImageLoader;

    public VideoAdapter(Context context, ImageLoader imageLoader, List<String> path) {
        mContext = context;
        mImageLoader = imageLoader;
        mPaths = path;
    }

    @Override
    public int getCount() {
        return mPaths.size();
    }

    @Override
    public String getItem(int position) {
        return mPaths.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = null;
        if ((view = convertView) == null) {
            view = View.inflate(mContext, R.layout.item_9_image, null);
        }
        ImageView imageView = (ImageView) view.findViewById(R.id.item_imageview);


//        ImageView imageView = null;
//        if ((imageView = (ImageView) convertView) == null) {
//            imageView = new ImageView(mContext);
//            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
//            imageView.setLayoutParams(new AbsListView.LayoutParams(300, 300));
//        }
        mImageLoader.loadImage(imageView, getItem(position));


        return view;
    }
}
